package com.nbsaas.boot.project.controller;

import com.nbsaas.boot.project.api.apis.ProjectTaskTagApi;
import com.nbsaas.boot.project.api.domain.request.ProjectTaskTagRequest;
import com.nbsaas.boot.project.api.domain.request.ProjectTaskTagSearch;
import com.nbsaas.boot.project.api.domain.response.ProjectTaskTagResponse;
import com.nbsaas.boot.project.api.domain.simple.ProjectTaskTagSimple;
import com.nbsaas.boot.rest.annotations.*;
import com.nbsaas.boot.rest.response.ListResponse;
import com.nbsaas.boot.rest.response.PageResponse;
import com.nbsaas.boot.rest.response.ResponseObject;
import jakarta.annotation.Resource;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 任务标签控制器
 */
@RequiresAuthentication
@RestController
@RequestMapping("/projectTaskTag")
public class ProjectTaskTagController {


    @Resource
    private ProjectTaskTagApi projectTaskTagApi;

    /**
     * 搜索数据
     *
     * @param request
     * @return
     */
    @SearchData
    @RequiresPermissions("projectTaskTag:search")
    @PostMapping("/search")
    public PageResponse<ProjectTaskTagSimple> search(@RequestBody ProjectTaskTagSearch request) {
        return projectTaskTagApi.search(request);
    }

    /**
     * 列表数据
     *
     * @param request
     * @return
     */
    @SearchData
    @RequiresPermissions("projectTaskTag:list")
    @PostMapping("/list")
    public ListResponse<ProjectTaskTagSimple> list(@RequestBody ProjectTaskTagSearch request) {
        return projectTaskTagApi.list(request);
    }

    /**
     * 添加数据
     *
     * @param request
     * @return
     */
    @RequiresPermissions("projectTaskTag:create")
    @CreateData
    @PostMapping("/create")
    public ResponseObject<ProjectTaskTagResponse> create(@RequestBody @Validated(AddOperator.class) ProjectTaskTagRequest request) {
        return projectTaskTagApi.create(request);
    }

    /**
     * 修改数据
     *
     * @param request
     * @return
     */
    @RequiresPermissions("projectTaskTag:update")
    @UpdateData
    @PostMapping("/update")
    public ResponseObject<ProjectTaskTagResponse> update(@RequestBody @Validated(UpdateOperator.class) ProjectTaskTagRequest request) {
        return projectTaskTagApi.update(request);
    }

    /**
     * 删除数据
     *
     * @param request
     * @return
     */
    @SearchData
    @RequiresPermissions("projectTaskTag:delete")
    @PostMapping("/delete")
    public ResponseObject<?> delete(@RequestBody @Validated(DeleteOperator.class) ProjectTaskTagRequest request) {
        return projectTaskTagApi.delete(request);
    }

    /**
     * 查看数据
     *
     * @param request
     * @return
     */
    @SearchData
    @RequiresPermissions("projectTaskTag:view")
    @PostMapping("/view")
    public ResponseObject<ProjectTaskTagResponse> view(@RequestBody @Validated(ViewOperator.class) ProjectTaskTagRequest request) {
        return projectTaskTagApi.view(request);
    }
}